import java.lang.invoke.MethodHandles
import java.lang.invoke.MethodType

class A<T : Any>(val data: T)
class B(val string: String) {
    fun getA(): A<*> = TODO()
}

fun test(a: A<*>, some: Any?): A<*> {
    a.data as B   // 注意这行对应的字节码
    a.data.string // 这里 a.data 有提示 Smart cast to B

    return if (some is B) some.getA() else A(Unit)
}

val concatString = MethodHandles.lookup().findVirtual(String::class.java,
        "concat", MethodType.methodType(String::class.java, String::class.java))

val str = concatString("我永远喜欢", "珂朵莉") as String // Boom！

fun main(args: Array<String>) {
}